#import "OrderTheFirstView.h"
#import <SDWebImage/UIImageView+WebCache.h>
@implementation OrderTheFirstView
{
    NSArray *_buttonArrray;
    NSString *class;
}
-(void)awakeFromNib
{
    [super awakeFromNib];
    ViewRadius(self.headerImage, 70/2);
    ViewBorderRadius(self.headerImage, 70/2, 1, MainColor);
    self.labcoin.textColor = MainColor;
    self.lablocal.textColor = MainColor;
    self.headerImage.contentMode = UIViewContentModeScaleAspectFill;
}
-(void)handleSwitchEvent:(UIButton *)button
{
    for (int i=0; i<_buttonArrray.count; i++) {
        UIButton *btn = _buttonArrray[i];
        btn.selected = NO;
    }
    button.selected = YES;
    NSString *switchType = @"";
    switch (button.tag) {
        case 3000:
            switchType = @"day";
            break;
        case 3001:
            switchType = @"week";
            break;
        default:
            break;
    }
    if([self.delegate respondsToSelector:@selector(switchType:)])
    {
        [self.delegate switchType:switchType];
    }
}
-(void)setView
{
    UIColor *tineColor = [UIColor qmui_colorWithHexString:@"DBDBDB"];
    NSLog(@"====type::%@",self.type);
    if([self.type isEqualToString:@"1"])
    {
        tineColor = MainColor;
    }
    else
    {
        tineColor = kGoldenColor;
        _rank_charm_image.image = IMAGE_NAMED(@"rank_wealth_champion");
        _top1.image = IMAGE_NAMED(@"rank_wealth_first");
        _top2.image = IMAGE_NAMED(@"rank_wealth_firstSide");
        _icon1.image = IMAGE_NAMED(@"rank_paycoin");
        _icon2.image = IMAGE_NAMED(@"rank_city_01");
        _lablocal.textColor = kGoldenColor;
        [self.level setTintColor:kGoldenColor];
        self.level.ghostColor = kGoldenColor;
    }
    _buttonArrray = @[_swbt1,_swbt2,_swbt3];
    for (int i=0; i<_buttonArrray.count; i++) {
        UIButton *btn = _buttonArrray[i];
        [btn addTarget:self action:@selector(handleSwitchEvent:) forControlEvents:UIControlEventTouchUpInside];
        btn.tag = 3000 + i;
        [btn setTitleColor:tineColor forState:UIControlStateSelected];
        [btn setTitleColor:[UIColor qmui_colorWithHexString:@"DBDBDB"] forState:UIControlStateNormal];
    }
    _myorder.textColor = [UIColor qmui_colorWithHexString:@"DBDBDB"];;
}
-(void)setOrderModel:(OrderModel *)orderModel
{
    _orderModel = orderModel;
    if(KIOSBASE)
    {
        self.headerImage.image = [[CYCommon sharedCYCommon] getKatongImageWidthID:orderModel.id];
    }
    else{
        [self.headerImage sd_setImageWithURL:[[CYURLUtils sharedCYURLUtils] safeUrl:orderModel.avatar] placeholderImage:emptyimage];
    }
    _nickname.text = orderModel.user_nickname;
    [_level getViewType:orderModel.sex AndLevel:orderModel.level];
    _labcoin.text = orderModel.zsum;
    _lablocal.text = orderModel.address;
    if([orderModel.is_online isEqualToString:@"1"]){
        UIImage *radImage = [[UIImage imageWithColor:MainColor size:CGSizeMake(3, 3)] imageByRoundCornerRadius:1.5];
        self.startus.image = radImage;
    }
    else
    {
        UIImage *radImage = [[UIImage imageWithColor:CLightGray size:CGSizeMake(3, 3)] imageByRoundCornerRadius:1.5];
        self.startus.image = radImage;
    }
    [self setView];
}
@end
